package es.decoroso.fakeAgent.behaviours;

import jade.core.AID;
import jade.core.behaviours.TickerBehaviour;
import jade.lang.acl.ACLMessage;

/**
 * This method send the position to the boat to the Graphic Layer.
 * 
 * 
 * @author Jesús Jiménez Castro
 */
public class NotifyGraphicLayerORI extends TickerBehaviour{

	/** Communication Agent */
	private AID com;
	/** Boat Agent */
	private es.decoroso.fakeAgent.Boat boat;
	/** Tick time in millisecond */
	private static int TICK = 50; 

	/**
	 * Constructor of the class
	 * 
	 * @param boat Agent boat
	 * @param com AID of the communication Agent
	 */
	public NotifyGraphicLayerORI(es.decoroso.fakeAgent.Boat boat, AID com) {
		super(boat, TICK);
		this.boat = boat;
		this.com = com;
		System.out.println("Starting notify graphic layer");
	}
	
	
	/**
	 * Send the update message to Communication Agent
	 */
	@Override
	protected void onTick() {
		ACLMessage msg = new ACLMessage(ACLMessage.INFORM);
		msg.addReceiver(com);
		// Send the message parsed to JSON
		msg.setContent(boat.createMessage().toJSON().toString());
		
		boat.send(msg);
	}
}
